unit ReportM;

interface

uses
  SysUtils, Classes, fr_class, FR_DBSet, DB, Forms, FMTBcd, SqlExpr;

type
  TReportModule = class(TDataModule)
    SQLDataSet1: TSQLDataSet;
  private
  public
    Rep: TfrReport;
    constructor Create(Filename: String=''); reintroduce;
    procedure AddDataset(Ds: TDataSet; Name: String='');
    procedure DesingReport;
  end;

implementation

{$R *.dfm}

{ TReportModule }

procedure TReportModule.AddDataset(Ds: TDataSet; Name: String);
var
  frDs : TfrDBDataSet;
begin
  frDs := TfrDBDataSet.Create(Self);
  frDs.DataSet := Ds;
  if Name <> '' then
  begin
    frDs.Name := Name;
  end
  else
  begin
    frDs.Name := Ds.Name;
  end;
end;

constructor TReportModule.Create(Filename: String);
begin
  inherited Create(nil);
  Rep := TfrReport.Create(Self);

  if FileExists(Filename) then
  begin
    Rep.LoadFromFile(Filename);
  end
  else
  begin
    Rep.FileName := Filename;
  end;
end;

procedure TReportModule.DesingReport;
begin
  Rep.DesignReport;
end;

end.
